# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: xguo

import sys
import datetime
import pathlib
import platform
import pandas as pd


#matplotlib.use('Agg')
import matplotlib.pyplot as plt


def main(_):
  df = pd.read_csv('/home/xguo/ok.csv')

  trade = df[df.type == "trade"]
  ts = pd.DatetimeIndex(trade.timestamp)
  price = trade.ask_price + trade.bid_price;
  trade.insert(2, 'price', price)
  plt.plot(ts, trade.price)

  book = df[df.type == "book"]
  ts = pd.DatetimeIndex(book.timestamp)
  price = (book.ask_price + book.bid_price) * 0.5
  book.insert(2, 'price', price)
  plt.plot(ts, book.price, '-.')
  plt.show()


if __name__ == '__main__':
  main(sys.argv)
